package com.wpen.unit.web.controller.system;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wpen.unit.service.system.MenuService;
import com.wpen.unit.web.dto.system.MenuListRequest;
import com.wpen.unit.web.dto.system.MenuListResponse;
import com.wpen.unit.web.dto.system.MenuTreeRequest;
import com.wpen.unit.web.dto.system.MenuTreeResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 菜单维护
 * 
 * @author pg
 *
 */
@Tag(name = "菜单模块服务接口")
@RestController
@RequestMapping("/api")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @Operation(summary = "菜单-列表查询")
    @PostMapping(value = "/menu/list", produces = MediaType.APPLICATION_JSON_VALUE)
    public MenuListResponse queryListMenu(@RequestBody @Valid MenuListRequest menuListRequest) {
        return menuService.queryListMenu(menuListRequest);
    }

    @Operation(summary = "菜单查询")
    @PostMapping(value = "/menu/tree", produces = MediaType.APPLICATION_JSON_VALUE)
    public MenuTreeResponse menuTree(@RequestBody MenuTreeRequest menuTreeParam) throws Exception {
        return menuService.menuTree(menuTreeParam);
    }

}
